<?php $this->start('admin_menu') ?>
<?php echo $this->element('admin_menu', array('str_item' => 'settings')) ?>
<?php $this->end(); ?>

<div class="sliders form">
    <?php echo $this->Form->create('Slider', array('type' => 'file')); ?>
    <h2><?php echo __('Sliders Management - Edit Slider'); ?></h2>
    <?php
    echo $this->Session->flash();
    echo $this->Session->flash('good');
    echo $this->Session->flash('bad');
    echo $this->Form->input('id');
    ?>
    <table class="form-table">
        <tr>
            <td class='l-style'><?php echo __('Name') ?><span class='star-rq'> * </span></td>
            <td class="r-style width_middle"><?php echo $this->Form->input('name', array('label' => false, 'class' => 'required')); ?></td>
        </tr>
        <tr>
            <td class='l-style'><?php echo __('Order') ?></td>
            <td class="r-style width_middle"><?php echo $this->Form->input('order', array('label' => false, 'default' => 0, 'maxlength' => 5, 'class' => 'number-mipt required digits')); ?></td>
        </tr>	
        <tr>
            <td class='l-style'><?php echo __('Size') ?></td>
            <td class="r-style width_middle">
                <?php echo $this->Form->input('width', array('label' => __("Width&nbsp;&nbsp;"), 'maxlength' => 5, 'readonly' => true, 'default' => 100, 'class' => 'number-mipt required digits', 'div' => false)); ?>
                <?php echo $this->Form->input('height', array('label' => __("Height&nbsp;&nbsp;"), 'maxlength' => 5, 'default' => 100, 'readonly' => true, 'class' => 'number-mipt required digits', 'div' => false)); ?>
            </td>
        </tr>		
        <tr>
            <td class='l-style'><?php echo __('Status') ?></td>
            <td class="r-style width_middle">
                <?php echo $this->Form->radio("status", array(Slider::hide => 'Hide', Slider::show => 'Show'), array('legend' => false, 'default' => Slider::hide)); ?>
            </td>
        </tr>
        <tr>
            <td class='l-style'><?php echo __('Slide') ?></td>
            <td class="r-style width_middle"><?php echo $this->Form->input('slide', array('label' => false)); ?></td>
        </tr>	
        <tr>
            <td class='l-style'><?php echo __('Images') ?></td>
            <td class="r-style width_middle">
                <table class="opt-val-tb" id="images-slider">
                    <tr>
                        <th><?php echo __('Order') ?></th>
                        <th><?php echo __('Image') ?></th>
                        <th><?php echo __('File') ?></th>
                        <th><?php echo __('Url') ?></th>
                        <th><?php echo __('Delete') ?></th>
                    </tr>
                    <?php foreach ($this->data['Image'] as $i => $img) { ?>
                        <tr>
                            <td class="col-no"><?php echo $this->Form->input('Image.' . $i . '.order', array('value' => $img['order'], 'label' => false, 'class' => 'number-mipt required digits')); ?></td>
                            <td class="post-img-small">
                                <?php echo $this->Images->showSmall($img) ?>
                            </td>
                            <td class="slider-images">
                                <?php
                                echo $this->Form->hidden('Image.' . $i . '.id', array('value' => $img['id']));
                                echo $this->Form->input('Image.' . $i . '.photo', array('label' => false, 'type' => 'file', 'class' => 'required'));
                                echo $this->Form->input('Image.' . $i . '.dir', array('type' => 'hidden', 'value' => $img['dir']));
                                echo $this->Form->input('Image.' . $i . '.mimetype', array('type' => 'hidden', 'value' => $img['mimetype']));
                                echo $this->Form->input('Image.' . $i . '.filesize', array('type' => 'hidden', 'value' => $img['filesize']));
                                ?>
                            </td>
                            <td style="width: 30%;"><?php echo $this->Form->input('Image.' . $i . '.url', array('label' => false, 'style' => 'width: 90%', 'value' => $img['url'])); ?></td>
                            <td style="width: 25%;text-align:center"><a href='#' onclick='removed(this);' class='act-lk del-link required'>Delete</a></td>
                        </tr>
                    <?php } ?>
                </table>
                <span id="add-more-slide" style="<?php echo $this->request->data['Slider']['slide'] == 1 ? 'display:block;' : 'display:none;' ?>" class="add-more-link" ><?php echo __('Add more image') ?></span>
            </td>
        </tr>				
        <tr>
            <td class='l-style no-border no-background'>
                (<span class='red-star'>*</span>) <?php echo __('Required') ?>
            </td>
            <td class='r-style actions no-border no-background'><?php echo $this->Form->end(__('Submit')); ?></td>
        </tr>
    </table>
</div>

<div class='actionct'>
    <span class='btn-act'><span><?php echo $this->Html->link(__('Back'), array('action' => 'index'), array('class' => 'back-act')); ?></span></span>
    <span class='btn-act'><span><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('Slider.id')), array('class' => 'del-link'), __('Are you sure you want to delete # %s?', $this->Form->value('Slider.id'))); ?></span></span>
</div>

<script type="text/javascript">
                            var countImages = <?php echo count($this->data['Image']) ?>;
</script>

